package cn.edu.jxau.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.jxau.service.queryPost;
/**
 * 这是对blog.jsp传递数据的servlet
 * @author 刘勋承
 *
 */
public class blogServlet extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		
		queryPost queryPost=new queryPost();
		
		//查询出每块模块的帖子数量
		request.getSession().setAttribute("totalByType1",queryPost.total("1"));
		request.getSession().setAttribute("totalByType2",queryPost.total("2"));
		request.getSession().setAttribute("totalByType3",queryPost.total("3"));
		request.getSession().setAttribute("totalByType4",queryPost.total("4"));
		//查询出所有帖子的数量
		request.getSession().setAttribute("total",queryPost.postTotal());
		//查询出在线人数
		request.getSession().setAttribute("onlineTotal",queryPost.onlineTotal());
		//查出最新的五个帖
		request.getSession().setAttribute("newTie", queryPost.findNewTie());
		//查出浏览量前五的帖
		request.getSession().setAttribute("PageView", queryPost.findPageView());
		response.sendRedirect("blog.jsp");
	}
}
